<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
	<script type="text/javascript">
		function my_otherFuns(value, row, index) {
			var see_info = "", see_process = "", to_submit = "",to_delete="";
			var infoprams = row.my_processID + ',' + row.my_taskId + ',"'
					+ row.my_processName + '"';
			var deleteprams = row.my_processID  + ',"'+ row.my_processName + '"';
			see_info = "<a onclick='look_info(" + infoprams
					+ ")' class='easyui-linkbutton button-teal handle-btn' >查看详情</a>";
			see_process = "<a onclick='look_process("+row.my_taskId+")' class='easyui-linkbutton button-blue handle-btn' >查看过程</a>";
			to_submit = "<a onclick='look_submit(" + deleteprams
					+ ")' class='easyui-linkbutton button-blue handle-btn' >提交</a>";
			to_delete="<a onclick='look_delete("+deleteprams+")' class='easyui-linkbutton button-darkblue handle-btn' >删除</a>"
			if (row.my_processState == "未开始") {
				return see_info + to_submit+to_delete;
			} else if (row.my_processState == "进行中"
					|| row.my_processState == "已完成") {
				return see_info + see_process;
			}
			return "";
		}
		function look_delete(processId,processName) {
			$.messager.confirm("警告","你确定要删除编号为‘"+processId+"’的‘"+processName+"’吗？",
					function(r) {
						if (r) {
							$.post("deleteProcess", {
								processName : processName,
								processId : processId
							}, function(info) {
								$("#myProcessesdg").datagrid("load");
								$.messager.alert("提示",info?"删除成功！":"删除失败！");
							});
						}
					}
			);
		}
		function look_process(taskId) {
			$("#see-my-process-layout-center-dg").datagrid({
				 url:'findAllAssignee?taskId='+taskId,
				 width:'100%',
				 height:'100%',
				 columns:[[
					 {field:'taskName',title:'任务名称',align:'center',width:'100'},
					 {field:'taskState',title:'任务状态',align:'center',width:'100'},
					 {field:'startTime',title:'开始时间',align:'center',width:'150'},
					 {field:'endTime',title:'结束时间',align:'center',width:'150'},
					 {field:'assignee',title:'办理人',align:'center',width:'100'}
				 ]]
			})
			$("#see-my-process").window("open");
		}
		function look_submit(processId,processName) {
			var processKey = "";
			if (processName=="人员录用流程") {
				processKey = 'employ_act';
			}else if (processName=="人员借款流程") {
				processKey = 'loan_act';
			}else if (processName=="人员离职流程") {
				processKey = 'quit_act';
			}else if (processName=="人员转正流程") {
				processKey = 'standard_act';
			}else if (processName=="人员加班流程") {
				processKey = 'overwork_act';
			}
			$.messager.confirm('消息', '您确定上传该流程吗？', function(r){
				if (r) {
					$.post("submit_readyemploys",{
						processId : processId,
						pk : processKey
					},function(data) {
						$("#myProcessesdg").datagrid("load");
						$.messager.alert("消息", data ? "提交成功！" : "提交失败！");
					});
				}
			})
			
		}
		function look_info(processId, taskId, processName) {
			$("#see-my-info").window({
				onBeforeClose:function(){
					$("#see-my-info-layout-center").panel("clear");
				}
			})
			$("#see-my-info").window("open");//打开窗口
			//给窗口填充内容
			if (processName == "人员录用流程") {
				$("#see-my-info-layout-center").panel({href : 'to_employForm',
					onLoad : function() {
						$.post("findProcess", {
							processName : processName,
							processId : processId
						}, function(info) {
							info.employBirth = new Date(info.employBirth).toLocaleDateString();
							info.employGraduatetime = new Date(info.employGraduatetime).toLocaleDateString();
							info.employPosttime = new Date(info.employPosttime).toLocaleDateString();
							$("#employForm").form("load", info);
						});
						//通过任务id去判断当前的批注填写方式，AJAX
						if (taskId != "") {
							$("#dept_boss").html('<input name="deptBoss" id="dept_boss_comment"> ');
							$("#personnel").html('<input name="personnel" id="personnel_comment">');
							$("#zong_boss").html('<input name="zongBoss" id="zong_boss_comment">');
							$("#zong_boss_comment").textbox({
								readonly : true,
								width : '70%',
								height : '100px',
								labelAlign : 'right',
								labelWidth : '90px',
								label : '总经理签字：',
								multiline : true
							});
							$("#personnel_comment").textbox({
								readonly : true,
								width : '70%',
								height : '100px',
								labelAlign : 'right',
								labelWidth : '90px',
								label : '人事归档：',
								multiline : true
							})
							$("#dept_boss_comment").textbox({
								readonly : true,
								width : '70%',
								height : '100px',
								labelAlign : 'right',
								labelWidth : '90px',
								label : '部门主管签字：',
								multiline : true
							})
							//装载已经有的批注
							$.post("getAllComments", {
								taskId : taskId
							}, function(comments) {
								$("#comments_form").form("load", comments);
							});
						} else {
							$("#comments_form").hide();
						}
					}
				});
			}else if(processName=="人员借款流程"){
				$("#see-my-info-layout-center").panel({href : 'to_loanForm',
					onLoad : function() {
						$.post("findProcess", {
							processName : processName,
							processId : processId
						}, function(info) {
							info.loanUptime = new Date(info.loanUptime).toLocaleDateString();
							$("#loanForm").form("clear");
							$("#loanForm").form("load", info);
						});
						//通过任务id去判断当前的批注填写方式，AJAX
						if (taskId != "") {
							$('#loan_dept_boss_comment').textbox('readonly',true);
							$('#loan_zong_boss_comment').textbox('readonly',true);
							$('#loan_finance_comment').textbox('readonly',true);
							//装载已经有的批注
							$.post("getAllComments", {taskId:taskId},function(comments){
								$("#comments_form").form("load", comments);
							});
						}else {
							$("#comments_form").hide();
						}
					}
				});
			}else if(processName=="人员请假流程"){
							
			}else if(processName=="人员转正流程"){
				$("#see-my-info-layout-center").panel({href : 'to_standardForm',
					onLoad : function() {
						$.post("findProcess", {
							processName : processName,
							processId : processId
						}, function(info) {
							$("#standardForm").form("clear");
							$("#standardForm").form("load", info);
						});
						//通过任务id去判断当前的批注填写方式，AJAX
						if (taskId != "") {
							$('#standard_dept_boss_comment').textbox('readonly',true);
							$('#standard_personnel_comment').textbox('readonly',true);
							//装载已经有的批注
							$.post("getAllComments", {taskId:taskId},function(comments){
								$("#comments_form").form("load", comments);
							});
						}else {
							$("#comments_form").hide();
						}
					}
				});
			}else if(processName=="人员调动流程"){
				
			}else if(processName=="人员还款流程"){
				
			}else if(processName=="人员加班流程"){
				$("#see-my-info-layout-center").panel({href : 'to_overworkForm',
					onLoad : function() {
						$.post("findProcess", {
							processName : processName,
							processId : processId
						}, function(info) {
							$("#overworkForm").form("clear");
							$("#overworkForm").form("load", info);
						});
						//通过任务id去判断当前的批注填写方式，AJAX
						if (taskId != "") {
							$('#overwork_dept_boss_comment').textbox('readonly',true);
							$('#overwork_personnel_comment').textbox('readonly',true);
							//装载已经有的批注
							$.post("getAllComments", {taskId:taskId},function(comments){
								$("#comments_form").form("load", comments);
							});
						}else {
							$("#comments_form").hide();
						}
					}
				});
			}else if(processName=="人员离职流程"){
				$("#see-my-info-layout-center").panel({href : 'to_quitForm',
					onLoad : function() {
						$.post("findProcess", {
							processName : processName,
							processId : processId
						}, function(info) {
							info.quitUptime = new Date(info.quitUptime).toLocaleDateString();
							info.quitTime = new Date(info.quitTime).toLocaleDateString();
							switch (info.quitType) {
							case "retire":
								info.quitType = "退休";
								break;
							case "illness":
								info.quitType = "病退";
								break;
							case "dismiss":
								info.quitType = "辞退";
								break;
							case "resign":
								info.quitType = "辞职";
								break;
							}
							$("#quitForm").form("clear");
							$("#quitForm").form("load", info);
						});
						//通过任务id去判断当前的批注填写方式，AJAX
						if (taskId != "") {
							$('#quit_dept_boss_comment').textbox('readonly',true);
							$('#quit_zong_boss_comment').textbox('readonly',true);
							$('#quit_personnel_comment').textbox('readonly',true);
							//装载已经有的批注
							$.post("getAllComments", {taskId:taskId},function(comments){
								$("#comments_form").form("load", comments);
							});
						}else {
							$("#comments_form").hide();
						}
					}
				});
			}else if(processName=="通知发布流程"){
				
			}
		}
		
		$(function() {
			$("#myProcessesdg").datagrid({
				onBeforeLoad : function(param) {
					param.my_processID = $("#my_processID").val();
					param.my_processState = $("#my_processState").val();
					param.my_processName = $("#my_processName").val();
				}
			});
			$("#find_my_processes_btn").linkbutton({
				onClick : function() {
					$('#myProcesses_search_from').form('submit',{
						onSubmit : function(param) {
							param.page = '1';
							param.rows = '10';
						},
						success : function(data) { //表单查询数据刷新DataGrid
							var resultData = $.parseJSON(data);
							$('#myProcessesdg').datagrid('loadData',resultData);
						}
					});
				}
			});
		})
	</script>
	<div
		style="width: 99%; height: 99%; border: 1px solid white; background: white">
		<div style="margin: 10px; height: 8%">
			<form action="find_my_processes" id="myProcesses_search_from" method="get">
				<input id="my_processID" name="my_processID" class="easyui-textbox"
					style="width: 20%;" label="流程编号：" labelAlign="right">
				<select id="my_processState" name="my_processState" class="easyui-combobox"
					style="width: 20%;" label="流程状态：" editable="false" labelAlign="right">
					<option value="">--请选择--</option>
					<option value="已完成">已完成</option>
					<option value="进行中">进行中</option>
					<option value="未开始">未开始</option>
				</select>
				<select id="my_processName" name="my_processName" class="easyui-combobox"
					style="width: 20%;" label="流程类别：" editable="false" labelAlign="right">
					<option value="">--请选择--</option>
					<option value="人员录用流程">录用申请单</option>
					<option value="人员转正流程">转正申请单</option>
					<option value="人员借款流程">借款申请单</option>
					<option value="人员请假流程">请假申请单</option>
					<option value="人员调动流程">调动申请单</option>
					<option value="人员还款流程">还款申请单</option>
					<option value="人员加班流程">加班申请单</option>
					<option value="人员离职流程">离职申请单</option>
					<option value="通知发布流程">通知申请单</option>
				</select>
				<a id="find_my_processes_btn" class="easyui-linkbutton button-line-blue"
					style="width: 10%; height: 30px; margin-left: 20px">检索</a>
			</form>
		</div>
		<table id="myProcessesdg" style="width: 99%; height: 500px"
			data-options="
				url:'find_my_processes',
				autoRowHeight:true,
				striped:true,
				pagination:true,
				rownumbers:true,
				singleSelect:true,
				remoteSort:false,
				pageSize:10,
				pageList:[10,15]
			">
			<thead>
				<tr>
					<th style="width: 10%" align="center"
						data-options="field:'my_processID',sortable:true">流程编号</th>
					<th style="width: 15%" align="center" data-options="field:'my_processName'">流程名称</th>
					<th style="width: 10%" align="center"
						data-options="field:'my_processState'">流程状态</th>
					<th style="width: 13%" align="center"
						data-options="field:'my_processStartTime',sortable:true">流程发起时间</th>
					<th style="width: 16%" align="center"
						data-options="field:'my_taskName',sortable:true">当前任务</th>
					<th style="width: 13%" align="center"
						data-options="field:'my_processEndTime',sortable:true">流程结束时间</th>
					<th style="width: 24%" align="center"
						data-options="field:'my_other',formatter:my_otherFuns">操作</th>
				</tr>
			</thead>
			<tbody>
			</tbody>
		</table>
		<div id="see-my-info" class="easyui-window" title="流程表单"
			data-options="collapsible:false,minimizable:false,maximizable:false,modal:true,iconCls:'icon-form',closed:true"
			style="width: 60%; height: 90%; padding: 5px">
			<div id="see-my-info-layout" class="easyui-layout" data-options="fit:true">
				<div id="see-my-info-layout-center" data-options="region:'center'"
					align="center" style="padding: 10px;"></div>
				<div data-options="region:'south',border:false"
					style="text-align: right; padding: 5px 0 0;">
					<a class="easyui-linkbutton"
						data-options="iconCls:'icon-cancel', plain:true" href="javascript:void(0)"
						onclick="$('#see-my-info').window('close');">取消</a>
				</div>
			</div>
		</div>
		<div id="see-my-process" class="easyui-window" title="流程过程"
			data-options="collapsible:false,minimizable:false,maximizable:false,modal:true,iconCls:'icon-form',closed:true"
			style="width: 50%; height: 70%; padding: 5px">
			<div id="see-my-process-layout" class="easyui-layout" data-options="fit:true">
				<div id="see-my-process-layout-center" data-options="region:'center'"
					align="center" style="padding: 10px;">
					<div id="see-my-process-layout-center-dg"></div>
				</div>
				<div data-options="region:'south',border:false"
					style="text-align: right; padding: 5px 0 0;">
					<a class="easyui-linkbutton"
						data-options="iconCls:'icon-cancel', plain:true" href="javascript:void(0)"
						onclick="$('#see-my-process').window('close');">取消</a>
				</div>
			</div>
		</div>
	</div>
</body>
</html>